package com.zt.jbpm.handler;

import org.apache.log4j.Logger;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.exe.ExecutionContext;

public class ReturnToLeaveActionHandler implements ActionHandler {
	
	private static Logger logger = Logger.getRootLogger();
	
	public void execute(ExecutionContext executionContext) throws Exception {
		Node node = executionContext.getTransitionSource();
		logger.info("进入[写请假条节点]，来源：" + node.getName());
		ContextInstance contextInstance = executionContext.getContextInstance();
		String reason = (String) contextInstance.getVariable("reason");
		if("部门经理审批".equals(node.getName())){
			reason = "[因经理没批准请假被驳回]" + reason;
		}else if("老板审批".equals(node.getName())){
			reason = "[因老板没批准请假被驳回]" + reason;
		}else if("判断请假天数".equals(node.getName())){
			reason = "[因请假天数大于1个月被系统驳回]" + reason;
		}
		
		contextInstance.setVariable("reason", reason);
	}

}
